Changing the values of a class returned by the array [] operator
Posted
by devdept
on Stack Overflow
See other posts from Stack Overflow
or by devdept
Published on 2010-05-06T15:20:29Z
Indexed on
2010/05/06
15:28 UTC
Read the original article
Hit count: 129
The question is: at the end of this code the value of ptArray[0].X is 3.33 or 1.11?
Thanks.
class MyPoint
{
public double X, Y;
public MyPoint(double x, double y)
{
X = x;
Y = y;
}
}
MyPoint[] ptArray = new MyPoint[2];
ptArray[0] = new MyPoint(1.11, 2.22);
MyPoint first = ptArray[0];
// Am I changing ptArray[0] here or not?
first.X = 3.33;
first.Y = 4.44;
© Stack Overflow or respective owner